﻿using System;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
using Avalonia;
using log4net;
using log4net.Config;

namespace ui_test;

sealed class Program
{
    // Initialization code. Don't use any Avalonia, third-party APIs or any
    // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
    // yet and stuff might break.

    private static readonly ILog log = LogManager.GetLogger(typeof(Program));

    [STAThread]
    public static void Main(string[] args)
    {
        try
        {
            XmlConfigurator.Configure(new FileInfo(@"config/log4net.xml"));
            
            log.Info("starting...");
            BuildAvaloniaApp()
                .StartWithClassicDesktopLifetime(args);
            AssemblyLoadContext.Default.Unloading += ctx => { log.Info("application is shutting down ..."); };
            log.Info("application started ...");
            
        }
        catch (Exception e)
        {
            log.Fatal(e);
        }
    }

    // Avalonia configuration, don't remove; also used by visual designer.
    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure<App>()
            .WithInterFont()
            .UsePlatformDetect()
            .WithInterFont()
            .LogToTrace();
}